<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>今天星期几</title>
	</head>
	<body>
		<h2 id="day"></h2>
		<script type="text/javascript">
			//从date 对象返回一周中的某一天（0~6）
			var date=new Date().getDay();
			//获取<h2>元素对象
			var h2=document.getElementById('day');
			var s="今天星期";
			switch(date){
				case 0:
				   s+="天";
				   break;
				case 1:
				   s+="一";
				   break;
				case 2:
				   s+="二";
				   break; 
				case 3:
				   s+="三";
				   break;
				case 4:
				   s+="四";
				   break;
				case 5:
				   s+="五";
				   break;   
			}
			//设置元素显示内容
			h2.innerText= s ;
		</script>
	</body>
</html>
